import React, { Component } from 'react'
import { Button, Text, View,StyleSheet } from 'react-native'

export default class UserShow extends Component {
    _update=uid=>{
        this.props.onSelectUpdate(uid)
    }
    //通过onDelete引用，调用父组件的_delete,并传入props.user.id
    _delete=uid=>{this.props.onDelete(uid)}
    render() {
        return (
            <View style={styles.user}>
                <Text style={styles.userTxt}> {this.props.user.uname} </Text>
                <Text style={styles.userTxt}> {this.props.user.address} </Text>
                <Button title="删除" onPress={()=>this._delete(this.props.user.id)}/>
                <Button title="更新" onPress={()=>this._update(this.props.user.id)}/>
            </View>
        )
    }
}
const styles = StyleSheet.create({
    user:{flexDirection:'row',justifyContent:'space-around'},
    userTxt:{fontSize:36}
})

